﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.IO;
using System.Xml.Linq;
//makecert -r -pe -a sha1 -n "CN=Windows Azure Authentication Certificate" -ss My -len 2048 -sp "Microsoft Enhanced RSA and AES Cryptographic Provider" -sy 24 skyazureauthentication.cer

namespace Infrastructure.Aspect.Services.AzureMgm
{
    public class AzureMgmService :IAzureMgmService
    {
        public string GetHostedServices(string CertFilename, string SuscriptionId)
        {
        
            var req = (HttpWebRequest)WebRequest.Create("https://management.core.windows.net/" + SuscriptionId + "/services/storageservices");
            req.Headers.Add("x-ms-version:2009-10-01");
            req.ClientCertificates.Add(X509Certificate2.CreateFromCertFile(CertFilename));
            var respStream = req.GetResponse().GetResponseStream();
            var xml = new StreamReader(respStream).ReadToEnd();
            return xml;
        }
    }
}
